<?php
/**
 * Created by PhpStorm.
 * User: zd
 * Date: 17-11-2
 * Time: 下午3:39
 */
$socket = socket_create(AF_INET,SOCK_STREAM,SOL_TCP);
socket_bind($socket,'0.0.0.0',4481);
socket_listen($socket);

$conn = socket_accept($socket);
$localAddress = '';
$localPort = 0;
socket_getsockname($conn,$localAddress,$localPort);
//var_dump($conn);
var_dump($localAddress,$localPort);
echo PHP_EOL;

$remoteAddress = '';
$remotePort = 0;
socket_getpeername($conn,$remoteAddress,$remotePort);
//var_dump($socket);
var_dump($remoteAddress,$remotePort);

///usr/bin/php /home/zd/zd04/tcpSockets/php/snippets/accept_connent_class.php
///  echo "123" | nc 127.0.0.1 4481
//string(9) "127.0.0.1"
//int(4481)
//
//string(9) "127.0.0.1"
//int(40010)
//
//Process finished with exit code 0